# Maintainer: Alexey Pavlov <alexpux@gmail.com>

_realname=sphinxcontrib-websupport
pkgbase=mingw-w64-python-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python2-${_realname}" "${MINGW_PACKAGE_PREFIX}-python3-${_realname}")
pkgver=1.0.1
pkgrel=1
arch=('any')
pkgdesc="Sphinx API for Web Apps (mingw-w64)"
url="http://www.sphinx-doc.org/"
license=('BSD')
makedepends=("${MINGW_PACKAGE_PREFIX}-python2" "${MINGW_PACKAGE_PREFIX}-python3" "${MINGW_PACKAGE_PREFIX}-python3-setuptools" "${MINGW_PACKAGE_PREFIX}-python2-setuptools")
source=("${_realname}-${pkgver}.tar.gz::https://github.com/sphinx-doc/sphinxcontrib-websupport/archive/${pkgver}.tar.gz")
sha256sums=('b320eda0c0127af2d86fee1b93d891d2ad6b660797220c5d7be8fdcc2d4db141')

prepare() {  
  cd "${srcdir}"  
  for pver in {2,3}; do 
    rm -rf python${pver}-build-${CARCH} | true
    cp -r "${_realname}-${pkgver}" "python${pver}-build-${CARCH}"
  done
}  

build() {  
  for pver in {2,3}; do  
    msg "Python ${pver} build for ${CARCH}"  
    cd "${srcdir}/python${pver}-build-${CARCH}"
    ${MINGW_PREFIX}/bin/python${pver} setup.py build
  done  
}

package_python3-sphinxcontrib-websupport() {
  depends=("${MINGW_PACKAGE_PREFIX}-python3")

  cd "${srcdir}/python3-build-${CARCH}"
  MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \
  ${MINGW_PREFIX}/bin/python3 setup.py install --prefix=${MINGW_PREFIX} --root=${pkgdir} --skip-build
}

package_python2-sphinxcontrib-websupport() {
  depends=("${MINGW_PACKAGE_PREFIX}-python2")

  cd "${srcdir}/python2-build-${CARCH}"
  MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \
  ${MINGW_PREFIX}/bin/python2 setup.py install --prefix=${MINGW_PREFIX} --root=${pkgdir} --skip-build
}

package_mingw-w64-i686-python2-sphinxcontrib-websupport() {
  package_python2-sphinxcontrib-websupport
}

package_mingw-w64-i686-python3-sphinxcontrib-websupport() {
  package_python3-sphinxcontrib-websupport
}

package_mingw-w64-x86_64-python2-sphinxcontrib-websupport() {
  package_python2-sphinxcontrib-websupport
}

package_mingw-w64-x86_64-python3-sphinxcontrib-websupport() {
  package_python3-sphinxcontrib-websupport
}
